<?php $yearstr=$str->getafteryear(0);?>
<?php $user=$session->read('User');
    $isflag=$action->checkPermissions($user,"confirm");
    $usertype=$action->checkPermissions($user,"utype");
    $userid=$user['id'];
    $state=($form->value('CompEconomic.state'));
    $value=($form->value('CompEconomic.creater'));
    //print_r($usertype);
?>
<div class="right_side_operate_area">
    <div class="right_side_title left">
        <h2>
        <?php 
        $companyname=$session->read("companyname");
        $companyid=$session->read("companyid");
        echo $html->link($companyname,"/companys/showinfosummary/".$companyid);
        ?>
        </h2>
        <div class='clear'></div>
    </div>
    <div class="right item_add_btn">
        <?php
            $cuser=$session->read('User'); 
            if($form->value('CompEconomic.id')){
            $str_title=__("Edit",true);
            }else{
            $str_title=__("Add",true);
            }
            echo $html->link(__("Cancel",true).$str_title,"/companys/economic/",array("onclick"=>"history.go(-1);return false;"));
        ?>
    </div>
    <div class="clear"></div>
</div>
<div class="right_side_scollbar">
    <div class="detail_info_panel">
        <?php 
        echo $form -> create('CompEconomic', array('url'=>'/companys/editeconomic','enctype'=>'multipart/form-data','onsubmit'=>'return checksave()') ); 
        ?>		
            <div class="details_item_line">
                <div class="details_item">
                    <div class="form_left_title left">年月：</div>
                    <div class="form_right_e_input left">
                    <?php 
                        $selectyear=null;
                        $id=$form->value("CompEconomic.id");
                        if(empty($id)){
                            $selectyear=date("Y",strtotime("now"));
                        }
                        echo $form->select('CompEconomic.company_year',$yearstr, $selectyear, null,null)
                    ?>
                    <?php 
                        $month=array("1"=>"01","2"=>"02","3"=>"03","4"=>"04","5"=>"05","6"=>"06","7"=>"07","8"=>"08","9"=>"09","10"=>"10","11"=>"11","12"=>"12");
                        echo $form->select('CompEconomic.month',$month,null,null,null);
                    ?>
                    </div>
                    <div id='yearmonthmessage' style='display:none;' class="error_message">本年度此月份已添加过</div>
                    <div id='stryear' style='display:none;'><?php echo $form->value('CompEconomic.company_year')?></div>
                    <div id='strmonth' style='display:none;'><?php echo $form->value('CompEconomic.month')?></div>
                </div>
            </div>
            <div class="details_item_line">		
                <div class="details_item">
                    <div class="form_left_title left"><font>总收入</font>：</div>
                    <div class="form_right_e_input left">
                    <?php if(($state=="1")&&(($userid==$value)||($isflag))){ ?>
                        <?php 
                            echo $form->text('CompEconomic.general_income',array("placeholder"=>"0.00","onkeydown"=>"checkpricekeyup(this,event)"));?> 万元
                            <?php }elseif($state!="1"){
                            echo $form->text('CompEconomic.general_income',array("placeholder"=>"0.00","onkeydown"=>"checkpricekeyup(this,event)"));?>   万元
                            <?php }else{
                            echo '<div class="form_right_input left">';
                            echo $form->value('CompEconomic.net_profit');
                            echo "&nbsp&nbsp&nbsp万元";
                            echo '</div>';
                            }?>
                         <div id='ecoincomemessage' style='display:none;' class="error_message">收入不能为空</div>
                    </div>
                </div>
                <div class="details_item">
                    <div class="form_left_title left">
                    <font>净利润</font>：</div>
                    <div class="form_right_e_input left">
                    <?php if(($state=="1")&&(($userid==$value)||($isflag))){ ?>
                        <?php echo $form->text('CompEconomic.net_profit',array("placeholder"=>"0.00","onkeydown"=>"checkpricekeyup(this,event)"));?> 万元
                        <?php }elseif($state!="1"){
                        echo $form->text('CompEconomic.net_profit',array("placeholder"=>"0.00","onkeydown"=>"checkpricekeyup(this,event)"));?> 万元
                        <?php }else{
                        echo '<div class="form_right_input left">';
                        echo $form->value('CompEconomic.net_profit');
                        echo "&nbsp&nbsp&nbsp万元";
                        echo '</div>';
                        }?>
                        <div id='ecoprofitmessage' style='display:none;' class="error_message">利润不能为空</div>
                    </div>     	
                </div>
                <div class="details_item">
                    <div class="form_left_title left">
                    <font>工业总产值</font>：</div>
                    <div class="form_right_e_input left">
                    <?php if(($state=="1")&&(($userid==$value)||($isflag))){ ?>
                        <?php echo  $form->text('CompEconomic.prospect',array("placeholder"=>"0.00","onkeydown"=>"checkpricekeyup(this,event)"));?> 万元
                        <?php }elseif($state!="1"){
                        echo $form->text('CompEconomic.prospect',array("placeholder"=>"0.00","onkeydown"=>"checkpricekeyup(this,event)"));?> 万元
                        <?php }else {
                        echo '<div class="form_right_input left">';
                        echo $form->value('CompEconomic.prospect');
                        echo "&nbsp&nbsp&nbsp万元";
                        echo '</div>';
                        }?>
                        <div id='ecoprospectmessage' style='display:none;' class="error_message">产值不能为空</div>
                    </div>
                </div>
            </div>
            <div class="details_item_line">
                <div class="details_item">
                    <div class="form_left_title left">
                    <font>产品销售额</font>：</div>
                    <div class="form_right_e_input left">
                    <?php if(($state=="1")&&(($userid==$value)||($isflag))){ ?>
                        <?php echo $form->text('CompEconomic.gross_output',array("placeholder"=>"0.00","onkeydown"=>"checkpricekeyup(this,event)"));?> 万元
                        <?php }elseif($state!="1"){
                        echo $form->text('CompEconomic.gross_output',array("placeholder"=>"0.00","onkeydown"=>"checkpricekeyup(this,event)"));?> 万元
                        <?php }else{
                        echo '<div class="form_right_input left">';
                        echo $form->value('CompEconomic.gross_output');
                        echo "&nbsp&nbsp&nbsp万元";
                        echo '</div>';
                        }?>
                        <div id='ecooutputmessage' style='display:none;' class="error_message">销售额不能为空</div>
                    </div>
                </div>
                <div class="details_item">
                    <div class="form_left_title left">
                    <font>利税</font>：</div>
                    <div class="form_right_e_input left">
                    <?php if(($state=="1")&&(($userid==$value)||($isflag))){ ?>
                        <?php echo $form->text('CompEconomic.pro_taxe',array("placeholder"=>"0.00","onkeydown"=>"checkpricekeyup(this,event)"));?> 万元
                        <?php }elseif($state!="1"){
                         echo $form->text('CompEconomic.pro_taxe',array("placeholder"=>"0.00","onkeydown"=>"checkpricekeyup(this,event)"));?> 万元
                        <?php }else{
                        echo '<div class="form_right_input left">';
                        echo $form->value('CompEconomic.gross_output');
                        echo "&nbsp&nbsp&nbsp万元";
                        echo '</div>';
                        }?>
                    </div>
                </div>
                <div class="details_item">
                    <div class="form_left_title left">
                    <font>上缴税金</font>：</div>
                    <div class="form_right_e_input left">
                    <?php if(($state=="1")&&(($userid==$value)||($isflag))){ ?>
                        <?php echo $form->text('CompEconomic.over_taxes',array("placeholder"=>"0.00","onkeydown"=>"checkpricekeyup(this,event)"));?> 万元
                        <?php }elseif($state!="1"){
                        echo $form->text('CompEconomic.over_taxes',array("placeholder"=>"0.00","onkeydown"=>"checkpricekeyup(this,event)"));?> 万元
                        <?php }else{
                        echo '<div class="form_right_input left">';
                        echo $form->value('CompEconomic.gross_output');
                        echo "&nbsp&nbsp&nbsp万元";
                        echo '</div>';
                        }?>
                        <div id='ecotaxesmessage' style='display:none;' class="error_message">上缴税金不能为空</div>
                    </div>
                </div>
            </div>
            <div class="details_item_line">
                <div class="details_item">
                    <div class="form_left_title left">出口创汇：</div>
                    <div class="form_right_e_input left">
                        <?php echo $form->text('CompEconomic.qcll',array("placeholder"=>"0.00","onkeydown"=>"checkpricekeyup(this,event)"));?> 万元
                        <div id='ecoqcllsmessage' style='display:none;' class="error_message">出口创汇不能为空</div>
                    </div>
                </div>
                <div class="details_item">
                    <div class="form_left_title left">减免税指标：</div>
                    <div class="form_right_e_input left">
                        <?php echo $form->text('CompEconomic.taxindex',array("placeholder"=>"0.00","onkeydown"=>"checkpricekeyup(this,event)"));?> 万元
                    </div>
                </div>
                <div class="details_item">
                    <div class="form_left_title left">高企减免税：</div>
                    <div class="form_right_e_input left">
                        <?php echo $form->text('CompEconomic.tax',array("placeholder"=>"0.00","onkeydown"=>"checkpricekeyup(this,event)"));?> 万元
                    </div>
                </div>
            </div>
            <div class="details_item_line">
                <div class="details_item">
                    <div class="form_left_title left">研发费减免税：</div>
                    <div class="form_right_e_input left">
                        <?php echo $form->text('CompEconomic.devtax',array("placeholder"=>"0.00","onkeydown"=>"checkpricekeyup(this,event)"));?>  万元
                    </div>
                </div>
            </div>
            <div class="details_item_line">
                <div class="details_item">
                   <div class="form_left_title left">财务报表：</div>
                    <div class="form_right_input left">
                        <?php if($attachments){?>
                        <div class="file_category_list">
                            <div id="filelist0" class="file_lists">
                                <ul class="file_attach">
                                    <?php
                                    $dan="'";				                	
                                    foreach($attachments as $attachment) {
                                            echo "<li>";
                                            echo "<span>".$html->link($attachment["file_name"],'/projects/download/'.$attachment["id"],null)."</span>";
                                            echo "<span class='source_upload_date'>".date("Y-m-d",strtotime($attachment["created"]))."</span>";											
                                            echo '<span class="source_upload_delete"><a title="删除" onclick="delfile(this,'.$dan.$attachment["id"].$dan.',0)" href="javascript:void(0)"></a></span>';
                                            echo "</li>";
                                    }
                                    ?>
                                </ul>
                            </div>
                        </div>
                        <?php }?>
                        <div id="add1" class="left text_box"> 
                            <div class="file_add_box">
                                <input type="file" id="upload[]" name="upload[]" />
                            </div>
                        </div>
                        <div class="clear"></div>
                        <div id="add2" class="left filelist"></div>
                        <div class="left clear">
                            <div class="left add_sub_file_btn">
                                <span onclick="add()" href="#"><?php echo $html->image('list-add.png')?></span>&nbsp;
                                <span onclick="remove()" href="#"><?php echo $html->image('list-remove.png')?></span>
                        </div>
                    </div>
                 </div>
                </div>
            </div>
            <div class="details_item_line">
            <div class="details_item">
                <div class="form_left_title left">审核状态：</div>
                <div class="form_right_input left">
                 <?php if($form->value('CompEconomic.state')=="1"){?>
                   <b><font color='green' size='3'>   <?php
                      echo "审核通过";?></font></b>
                <?php  }else if($form->value('CompEconomic.state')=="0"){
                echo '<b>';
                echo '<font color=red size=3 weight=bold>';
                echo "审核中";
                echo '</font>';
                echo '</b>';
                }else if($form->value('CompEconomic.state')=="2"){
                    echo '<b>';
                    echo '<font color=black size=3 weight=bold>';
                    echo "被驳回";
                    echo '</font>';
                    echo '</b>';  
                }else{
                	 echo '<b>';
                    echo '<font color=black size=3 weight=bold>';
                    echo "等待";
                    echo '</font>';
                    echo '</b>';  
                }?>
                </div>
            </div>
        </div>
        <?php if($user["cid"]){?>
        <div class="details_item_line">
            <div class="details_item">
                <div class="form_left_title left"></div>
                <div class="form_right_input left" style="margin-left: 95px;">
                <input type="checkbox" name="boss_check" id="boss_check" value="1">已经过老板核实!
                </div>
            </div>
        </div>
        <?php }?>
            <?php
            echo $form->hidden('CompEconomic.owner',array('value' => $cuser['id'])) ; 
            echo $form->hidden('CompEconomic.cid',array('value' => $_SESSION['companyid'])) ;
            echo $form->hidden('CompEconomic.id') ;
            ?>
             <div class="details_item_line">
                <div class="details_item">
                    <div class="form_left_title left"></div>
                    <div class="form_add_submit left">
                        <?php echo $form->submit(__('保存并提交',true), array("name"=>"submit","div"=>false)) ?>
                        <?php 
                        if($user["cid"]){
                        	echo $form->submit(__('保存并提交',true), array("name"=>"submit","id"=>"save_id","div"=>false));
                        }
                        ?>
                         <?php  echo $form->hidden('CompEconomic.id'); ?>
                          <?php  echo $form->hidden('CompEconomic.creater'); ?>
                    </div>
                </div>
             </div>		
    </div>
</div>
<?php echo $this->element('delfileconfirm',array("title"=>"删除提示","message"=>"你确定要删除吗？")) ?>
<script>
var webpath=$("#getpath").attr('href');
$(document).ready(function()
{   
    $("div.selector").css("width","69px");
    $("div.selector span").css("width","40px");
    $("div.selector select").css("min-width","73px");
    
    $("#CompEconomicCompanyYear").change(function() {  
        var strmonth=$("#CompEconomicMonth").val();
        checkyearmonth(this.value,strmonth);
    });
    $("#CompEconomicMonth").change(function() {  
        var stryear=$("#CompEconomicCompanyYear").val();
        checkyearmonth(stryear,this.value);
    });
    
    if(!$("#boss_check").attr("checked")!="checked"){
        $("#save_id").attr("disabled","disabled"); 
    }
    $("#boss_check").click(function(){
        if($(this).attr("checked")=="checked"){
           $("#save_id").removeAttr("disabled"); 
        }else{
            $("#save_id").attr("disabled","disabled"); 
        }
    
    });
});

function checkyearmonth(stryear,strmonth){
    if(stryear.trim()!=""){
        var stryears=$("#stryear").html();
        var strmonths=$("#strmonth").html();
        if(stryears!=stryear && strmonths!=strmonth){
            var urlpath=webpath+'companys/checkyearmonth/'+stryear+'/'+strmonth;
            $.ajax({     	   
                   url: urlpath, 
                   success:function(data){
                        if(data=="1")
                        {
                            $("#yearmonthmessage").css('display','block');
                        }else{
                            $("#yearmonthmessage").css('display','none');
                        }
                    }
                });
            }else{
                $("#yearmonthmessage").css('display','none');
            }
        }else{
            $("#yearmonthmessage").css('display','block');
        }		
    }	
var cyear=$("#CompEconomicCompanyYear").val();
var cmonth=$("#CompEconomicMonth").val();
checkyearmonth(cyear,cmonth);
function checksave()
{
    if($("#yearmonthmessage").css('display')=="block"){
        return false;
    }
}
</script>